<?php

/*
|--------------------------------------------------------------------------
| 管理后台的路由
|--------------------------------------------------------------------------
|
| web中间件定义在HTTP/kernel.php中，包含了session、CSRF保护等等
|
*/

Route::group(['prefix' => 'api_admin', 'middleware' => 'web', 'namespace' => 'Admin'], function () {
	// 认证
	Route::get('/login', 'Auth\LoginController@showLoginForm');
    Route::post('/login', 'Auth\LoginController@login');
    Route::get('/logout', 'Auth\LoginController@logout');
});

Route::group(['prefix' => 'api_admin', 'middleware' => ['web', 'auth:admin'], 'namespace' => 'Admin'], function () {

	Route::get('/', 'AdminController@index')->name('admin');
	Route::get('/getJson', 'AdminController@getJson');

	/**
	 * 
	 * 超级管理员 
	 * @var 管理员用户
	 * @var RBAC - Role
	 * @var RBAC - Permission
	 * 
	 */
	Route::group(['middleware' => 'role:administrator'], function () {
		Route::get('managers/index', 'Manager\UserController@index')->name('managers');

		Route::resource('managers', 'Manager\UserController');
		Route::get('role/index', 'Manager\RoleController@index')->name('role');
		Route::resource('role', 'Manager\RoleController');
		Route::get('permission/index', 'Manager\PermissionController@index')->name('permission');
		Route::resource('permission', 'Manager\PermissionController');
	});
	
	/**
	 * 管理员账户资料管理
	 */
	Route::get('profile/show', 'Manager\ProfileController@show')->name('profile');
	Route::post('profile/{id}', 'Manager\ProfileController@update');
	Route::post('profile/password/reset', 'Manager\ProfileController@reset');

	/**
	 * imlooke用户管理
	 */
	Route::get('users', 'Imlooke\UserController@index')->name('users');
	Route::get('users/{id}', 'Imlooke\UserController@show');

	/**
	 * imlooke活动管理
	 */
	Route::get('activities', 'Imlooke\ActivityController@index')->name('activities');
	Route::get('activities/{id}', 'Imlooke\ActivityController@show');

	/**
	 * imlooke用户分享管理
	 */
	Route::get('tweets/index', 'Imlooke\TweetController@index')->name('tweets');
	Route::resource('tweets', 'Imlooke\TweetController');

	/**
	 * imlooke用户反馈处理
	 */
	Route::get('feedback/index', 'Imlooke\FeedbackController@index')->name('feedback');
	Route::resource('feedback', 'Imlooke\FeedbackController');
});
